<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String path8 = request.getContextPath();
    String basePath8 = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path8 + "/";
%>
<%--修理厂--%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript"
            src="<%=path8%>/HoganJS/handlebars-v4.0.11.js"></script>
    <title>Insert title here</title>
    <style type="text/css">
        li span {
            margin-left: 0px;
            cursor: pointer;
        }

        li span:hover {
            color: #427dff
        }

        .modal-data8 {
            visibility: hidden;
            z-index: 1001;
            min-height: 500px;
            margin: 100px auto;
            background-color: #FFFFFF;
            /* border: 1px solid #C80B14;*/
            -moz-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
            -webkit-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
            /*         box-shadow:0 0 10px #cccccc;
            box-shadow: #cccccc; */
            box-shadow: 0 10px 20px #57a1ff inset, 0 -10px 0 #57a0ff inset;
            padding: 5px;
            text-align: center;
            position: fixed;
            left: 22%;
        }
    </style>
</head>
<body>
<div id="modal-overlay"></div>
<div class="modal-data8">
    <div style="height: 60px">
        <ul>
            <li style="text-align: left;margin-left: 60px;height: 40px;line-height: 40px">
                <span>名称：</span>
                <span>
				  		 	<input class="name2" id="name2" type="text">
				  		</span>
                <span>
				  			<button class="findBtn2" id="findBtn4">
				  				查询
				  			</button>
				  		</span>
            </li>
        </ul>
    </div>
    <div style="width:1000px; height:350px; overflow:scroll;">
        <form action="">
            <table class="repList" id="repList" style="width: auto;white-space:nowrap;border-spacing: 0px">
            </table>
        </form>
    </div>
    <button class="subtn2" id="subtn8" style="width: 150px;position: absolute;bottom: 25px;font-size: 16px;left: 280px">
        确定
    </button>
    <button class="btn" style="width: 150px;position: absolute;bottom: 25px;font-size: 16px;right: 280px">
        关闭
    </button>
</div>
<script type="text/javascript" src="<%=path8%>/JQuery/jquery-1.8.2.js"></script>
<script id="table-template-rep" type="text/x-handlebars-template">
    <tr style="background: #f2f2f2;height: 30px;line-height: 20px;" class="sel">
        <td style="width: 20px"></td>
        <td>名称</td>
        <td>编码</td>
        <td>简称</td>
        <td>描述</td>
        <td>创建时间</td>
        <td>用户名</td>
        <td>最后修改时间</td>
        <td>用户名</td>
        <td>财务组织</td>
    </tr>
    {{#each this}}
    <tr class="jx">
        <td><input type="checkbox" value="{{fid}}" name="train3"/></td>
        <td>{{fnameL2}}</td>
        <td>{{fnumber}}</td>
        <td>{{fsimplename}}</td>
        <td>{{fdescriptionL2}}</td>
        <td>{{fcreatetime}}</td>
        <td>{{createName}}</td>
        <td>{{flastupdatetime}}</td>
        <td>{{updateName}}</td>
        <td>{{companyName}}</td>
    </tr>
    {{/each }}

</script>
<script type="text/javascript">

    //弹出框模版文件
    var myTemplaterep = Handlebars.compile($("#table-template-rep").html());

    //注册一个比较内容是否为空
    Handlebars.registerHelper("isNull", function (v1, options) {
        if (v1 != "") {
            //满足添加继续执行
            return options.fn(this);
        } else {
            //不满足条件执行{{else}}部分
            return options.inverse(this);
        }
    });

    //注册一个比较大小的Helper,判断v1是否大于v2
    Handlebars.registerHelper("compare", function (v1, v2, options) {
        if (v2 == 100) {
            //满足添加继续执行
            return options.fn(this);
        }
        if (v1 == v2) {
            //满足添加继续执行
            return options.fn(this);
        } else {
            //不满足条件执行{{else}}部分
            return options.inverse(this);
        }
    });


    //根据名称查询维修项目弹窗
    $("#findBtn4").live('click', function () {
        var name2 = $("#name2").val();
        $('.head2').html("<div class='loading'></div>");
        $.ajax({
            url: '<%=path8%>/DrivingSys/select_RepairShop',
            type: "post",
            data: {'name': name2},
            dataType: "json",
            success: function (json) {
                $('.repList').html(myTemplaterep(json));
                $(".name2").val(name2)
            },
            error: function () {
                alert('错误');
            }
        })
    })

    //单击选中
    $(document).on('click', '#repList tr td:not(td:first-child)', function () {
        if ($(this).parent().find("input:checkbox").is(':checked')) {
            $(this).parent().find("input:checkbox").removeAttr("checked");
        } else {
            $(this).parent().find("input:checkbox").attr("checked", ":checked")
        }
    })
    //双击
    $(document).on('dblclick', '#repList tr td:not(td:first-child)', function () {
        $(this).parent().find("input:checkbox").attr("checked", ":checked")
        $('#subtn8').click();
    })

</script>
</body>
</html>